-
Notifications
You must be signed in to change notification settings - Fork 411
Fix #2210 #2212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #2210 #2212
Conversation
adamsitnik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing the bug!
|
|
||
| if (validatedResult.Result == ArgumentConversionResultType.Successful | ||
| && convertedResult.Result == ArgumentConversionResultType.NoArgument) | ||
| if (validatedResult is { Result: ArgumentConversionResultType.Successful } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you find this syntax more readable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer it as a best practice because the behavior of == can be changed by operator overloading.
| } | ||
| } | ||
| else if (argument.ValueType == typeof(bool) && | ||
| else if ((argument.ValueType == typeof(bool) || argument.ValueType == typeof(bool?)) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
BTW a while ago I have introduced a helper method for that:
| internal bool IsBoolean() => ValueType == typeof(bool) || ValueType == typeof(bool?); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing it out! I've updated to use that in my other PR.
This fixes #2210. The issue was that
boolparsing had a special case in place so that it doesn't consume the following token if that token can't be parsed as a bool. This lets the unparseable token by consumed by a different symbol, which is typically the intent.The fix includes
bool?in that special case.